package com.etc.my.service.impl;

import com.etc.my.dao.MyCollectionDao;
import com.etc.my.dto.CollectionAndCarMessageDto;
import com.etc.my.dto.CollectionDto;
import com.etc.my.dto.CountDto;
import com.etc.my.service.MyCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyCollectionServiceImpl implements MyCollectionService {
    @Autowired
    private MyCollectionDao dao;

    public MyCollectionDao getDao() {
        return dao;
    }

    public void setDao(MyCollectionDao dao) {
        this.dao = dao;
    }

    @Override
    public List<CollectionAndCarMessageDto> getCollectionByUserIdOfPage(Integer userId, Integer page, Integer size) {
        return dao.qyeryCollectionByUserIdOfPage(userId, page, size);
    }

    @Override
    public CountDto getCollectionCountByUserId(Integer userId) {
        return dao.queryCollectionCountByUserId(userId);
    }

    @Override
    public boolean cancelCollectionById(Integer collection_id) {
        return dao.deleteCollectionById(collection_id);
    }

    @Override
    public boolean addCollection(Integer user_id, String car_id) {
        return dao.insertCollection(user_id,car_id);
    }

    @Override
    public boolean isCollection(Integer user_id, String car_id) {
        CollectionAndCarMessageDto result = dao.isCollection(user_id,car_id);
        if(result!=null){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public boolean cancelCollectionByCarAndUserId(Integer user_id, String car_id) {
        return dao.cancelCollectionByCarAndUserId(user_id,car_id);
    }
}
